﻿<!--
Filename: ZoomImage.xaml
Version: 20140612
Author: George Birbilis (http://zoomicon.com)  
-->

<UserControl x:Class="ZoomImage.ZoomImage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:zoom="clr-namespace:ZoomAndPan;assembly=ZoomAndPan"  
    xmlns:btn="clr-namespace:ImageButtons;assembly=ImageButtons"  
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="300"
    BorderThickness="0"
    AllowDrop="True"         
             
    SizeChanged="UserControl_SizeChanged"
    MouseEnter="UserControl_MouseEnter"
    MouseLeave="UserControl_MouseLeave"
    >

  <VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="DragStates">
      <VisualStateGroup.Transitions>
        <VisualTransition GeneratedDuration="0:0:0.3">
          <VisualTransition.GeneratedEasingFunction>
            <CircleEase EasingMode="EaseIn"/>
          </VisualTransition.GeneratedEasingFunction>
        </VisualTransition>
      </VisualStateGroup.Transitions>
      <VisualState x:Name="Normal"/>
      <VisualState x:Name="DragOver">
        <Storyboard>
          <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ContentBorder"> <!-- TODO: change TargetName -->
            <EasingColorKeyFrame KeyTime="0" Value="#FFFFF7D1"/>
          </ColorAnimationUsingKeyFrames>
        </Storyboard>
      </VisualState>
    </VisualStateGroup>
  </VisualStateManager.VisualStateGroups>

  <Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
      <RowDefinition />
    </Grid.RowDefinitions>

    <MultiScaleImage
      Name="imgDeepZoom"
      Grid.Row="0"
      Visibility="Collapsed"
      MouseLeftButtonDown="control_MouseLeftButtonDown"
      MouseLeftButtonUp="control_MouseLeftButtonUp"
      MouseRightButtonDown="control_MouseRightButtonDown"
      MouseMove="control_MouseMove"
      MouseWheel="control_MouseWheel"
      ImageOpenSucceeded="control_ImageOpenSucceeded"
      />

    <ScrollViewer
      Name="scrollPlainZoom"
      Grid.Row="0"
      HorizontalScrollBarVisibility="Auto"
      VerticalScrollBarVisibility="Auto"
      BorderThickness="0"
      Visibility="Collapsed"
      >

      <zoom:ZoomAndPanControl
        Name="imgPlainZoom"
        BorderThickness="0"
        MouseLeftButtonUp="control_MouseLeftButtonUp"
        MouseRightButtonDown="control_MouseRightButtonDown"
        IsDefaultMouseHandling="True"
        > <!-- handling MouseLeftButtonDown MouseWheel in code -->
        <Image
          Name="imgPlain"
          Stretch="None"
          ImageOpened="control_ImageOpenSucceeded" />
      </zoom:ZoomAndPanControl>

    </ScrollViewer>

    <StackPanel
      Name="zoomControls"
      Grid.Row="0"
      Orientation="Horizontal"
      HorizontalAlignment="Right" VerticalAlignment="Bottom" 
      Margin="25"
      Visibility="Collapsed"
      >
      <StackPanel.Resources>
        <Style TargetType="btn:ImageButton">
          <Setter Property="Margin" Value="2" />
        </Style>
      </StackPanel.Resources>

      <btn:ImageButton
        Name="btnZoomIn"
        Image="Images/ZoomIn.png"
        ImageHover="Images/ZoomIn_hover.png"
        Click="btnZoomIn_Click"
        />

      <btn:ImageButton
        Name="btnZoomOut"
        Image="Images/ZoomOut.png"
        ImageHover="Images/ZoomOut_hover.png"
        Click="btnZoomOut_Click"
        />

      <btn:ImageButton
        Name="btnZoomToFit"
        Image="Images/ZoomToFit.png"
        ImageHover="Images/ZoomToFit_hover.png"
        Click="btnZoomToFit_Click"
        />

    </StackPanel>


  </Grid>

</UserControl>
